package com.efast.dmom.mes.util;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author Aaron Liu
 * @version Creation Time：2020年1月8日 下午5:34:23
 */
public class TimeUtil {

	public static Date getLocalDate() {

		ZoneId zoneId = ZoneId.systemDefault();

		ZonedDateTime zoneDateTime = getLocalDateTime().atZone(zoneId);

		return Date.from(zoneDateTime.toInstant());
	}

	public static LocalDateTime getLocalDateTime() {

		ZoneId zoneId = ZoneId.systemDefault();
		Instant instant = new Date().toInstant();

		return instant.atZone(zoneId).toLocalDateTime();
	}

	public static LocalDateTime getMaxLocalDateTime() {

		ZonedDateTime maxTime = ZonedDateTime.of(LocalDate.of(9999, 12, 30), LocalTime.MAX, ZoneId.systemDefault());

		return maxTime.toLocalDateTime();
	}

	public static String getLocalDateTimeStr() {

		DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		return timeFormatter.format(getLocalDateTime());
	}

	/**
	 * 获取当前时区
	 **/
	public static String getLocalTimeZone() {
		return TimeZone.getDefault().getID();
	}
}
